<script>
  /*
  * Copyright (c) 2012-2013 RockStor, Inc. <http://rockstor.com>
  * This file is part of RockStor.
  *
  * RockStor is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published
  * by the Free Software Foundation; either version 2 of the License,
  * or (at your option) any later version.
  *
  * RockStor is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  *
  */
</script>
<div class="row">
<div class="col-md-8">
<div class="panel panel-default">
<div class="panel-heading">Setup Email for alerts</div>
<div class="panel-body">

  <form id="email-form" name="email-form" class="form-horizontal" autocomplete="off">
    <div class="messages"></div>
    <div class="form-group">
      <label class="col-sm-4 control-label">Name<span class="required"> *</span></label>
      <div class="col-sm-4">
      <input class="form-control" type="text" id="name" name="name" {{add_email "name"}}>
      </div>
    </div>

    <div class="form-group">
      <label class="col-sm-4 control-label">Sender email<span class="required"> *</span></label>
      <div class="col-sm-4">
      <input class="form-control check-smtp-auth" type="email" id="sender" name="sender" {{add_email "email"}}>
      </div>
    </div>

    <div class="form-group">
      <div class="col-sm-offset-4 col-sm-8">
        <label class="checkbox inline">
          <input type="checkbox" id="enable_username" name="enable_username"> Force username for SMTP Authentication
        </label>
      </div>
    </div>

    <div class="form-group">
      <label class="col-sm-4 control-label">Username<span class="required"> *</span></label>
      <div class="col-sm-4">
      <input class="form-control check-smtp-auth" type="text" id="username" name="username" {{add_email "username"}} disabled="true">
      </div>
    </div>

    <div class="form-group">
      <label class="col-sm-4 control-label">Password<span class="required"> *</span></label>
      <div class="col-sm-4">
        <input class="form-control check-smtp-auth" type="password"  name="password" title="Password for the above email address">
      </div>
    </div>

    <div class="form-group">
      <label class="col-sm-4 control-label">SMTP Server<span class="required"> *</span></label>
      <div class="col-sm-4">
      <input class="form-control check-smtp-auth" type="text" id="smtp_server" name="smtp_server" {{add_email "smtp"}}>
      </div>
    </div>

    <div class="form-group">
      <label class="col-sm-4 control-label">SMTP Port</label>
      <div class="col-sm-4">
	<input class="form-control check-smtp-auth" type="text" id="port" name="port" {{add_email "port"}}>
      </div>
    </div>

    <div class="form-group">
      <div class="col-sm-offset-4 col-sm-8">
        <label class="radio inline">
          <input type="radio" name="secured_connection" value="TLS" checked> Secured connection using TLS
        </label>
      </div>
    </div>

    <div class="form-group">
      <label class="col-sm-4 control-label">Recipient Email<span class="required"> *</span></label>
      <div class="col-sm-4">
      <input class="form-control" type="email" id="receiver"  name="receiver" {{add_email "recipient"}} >
      </div>
    </div>

    <div class="form-group">
      <div class="col-xs-8 col-xs-offset-4">
        <a id="cancel" class="btn btn-default">Cancel</a>
        <input type="Submit" id="add-email" class="btn btn-primary" value="Submit"></input><br/><br/>
		<button type="button" id="test-smtp" class="btn btn-primary">Test current SMTP params</button>
      </div>
    </div>
  </form>
  <div class="alert alert-success auth-results" id="auth_success" style="display: none;">
  <strong>SMTP Authentication was successful</strong> Save your settings
  </div>
  <div class="alert alert-danger auth-results" id="auth_failed" style="display: none;">
  <strong>SMTP Authentication failed!</strong> Please update your settings before saving.
  <br/>If using a Google account please remember to enable
  <a target="_new" href="https://support.google.com/mail/answer/185833">App Passwords</a> after 
  <a terget="_new" herf="https://support.google.com/accounts/answer/185839">Google 2-Step Verification</a> or
  <a target="_new" href="https://support.google.com/a/answer/6260879">Allow less secure apps to access accounts</a>
  </div>
</div><!--panel-body-->
</div><!--col-md-8 -->
</div><!--panel-default -->
</div><!-- row-->

